/*
 * @Author: your name
 * @Date: 2021-11-09 16:30:21
 * @LastEditTime: 2021-12-13 14:13:57
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \li-yuwei\egg-example\app\controller\home.js
 */
"use strict";
const Mock = require("mockjs");
const { list } = Mock.mock({
    "list|10": [{
        name: "@ctitle",
        province: "@province",
        city: "@city",
        area: "@area",
        "price|20000-40000": 1,
        "order|1-9": 1,
        update_time: "@datetime",
    }, ],
});
const Controller = require("../core/base_controller");
class HousingController extends Controller {
    async insert() {
            const { ctx, app } = this;
            list.forEach((item) => {
                app.mysql.insert("housing", {...item });
            });
            ctx.body = "操作成功";
        }
        //获取列表
    async getHousingList() {
            const { ctx, app } = this;
            try {
                const res = await ctx.service.housing.getHousingList();
                this.success(res);
            } catch (err) {
                this.error(err.message);
            }
        }
        //添加
    async addHousingList() {
            const { ctx, app } = this;
            try {
                const res = await ctx.service.housing.addHousingList();
                this.success(res);
            } catch (err) {
                this.error(err.message);
            }
        }
        //删除
    async delHousingList() {
            const { ctx, app } = this;
            try {
                const res = await ctx.service.housing.delHousingList();
                this.success(res);
            } catch (err) {
                this.error(err.message);
            }
        }
        //修改
    async editHousingList() {
            const { ctx, app } = this;
            try {
                const res = await ctx.service.housing.editHousingList();
                this.success(res);
            } catch (err) {
                this.error(err.message);
            }
        }
        //改变状态
    async changeHousingState() {
            const { ctx, app } = this;
            try {
                const res = await ctx.service.housing.changeHousingState();
                this.success(res);
            } catch (err) {
                this.error(err.message);
            }
        }
        //指派经纪人
    async designBroker() {
        const { ctx, app } = this;
        try {
            const res = await ctx.service.housing.designBroker();
            this.success(res);
        } catch (err) {
            this.error(err.message);
        }
    }
}

module.exports = HousingController;